/*
 * DeleteRouteAction.java
 * 
 * Created by demory on Jun 7, 2008, 9:01:55 PM
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.apps.rtemaster.actions;

import org.fpdev.core.transit.Route;
import org.fpdev.apps.rtemaster.RouteMaster;

/**
 *
 * @author demory
 */
public class DeleteRouteAction implements ACAction {

  private Route rteCopy_;
  private String combID_;

  public DeleteRouteAction(String combID) {
    combID_ = combID;
  }

  public boolean doAction(RouteMaster av) {
    rteCopy_ = new Route(av.getRouteOps().getRoutes().getRoute(combID_), av.getEngine());
    av.getRouteOps().getRoutes().getRoute(combID_).clearSubRoutes(av.getEngine().getRouteNetwork());
    av.getRouteOps().getRoutes().getMap().remove(combID_);
    av.getRouteOps().getRoutes().changesMade();
    av.getGUI().getRouteSelectionPanel().updateRoutes();
    return true;
  }

  public boolean undoAction(RouteMaster av) {

    av.getRouteOps().getRoutes().add(rteCopy_);
    av.getGUI().getRouteSelectionPanel().updateRoutes(true);
    av.getGUI().getRouteSelectionPanel().selectRouteByID(rteCopy_.getID());
    return true;
  }

  public String getName() {
    return "Delete Route";
  }
}
